package com.tangdi.production.mpaychl.service.impl.DeShiPay;

import com.acq.sdk.EncodeUtils;
import com.tangdi.production.mpaychl.base.service.BaseTranService;
import com.tangdi.production.mpbase.constants.ExcepCode;
import com.tangdi.production.mpbase.constants.MsgCT;
import com.tangdi.production.mpbase.constants.TranCode;
import com.tangdi.production.mpbase.exception.BusinessException;
import com.tangdi.production.mpbase.exception.TranException;
import com.tangdi.production.mpbase.util.*;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.*;

/**
 * <b>DeShiPay</b>网银交易[外发]渠道公共处理流程接口实现
 * 
 * @author XY 2018/09/25
 *
 */
@SuppressWarnings("unused")
@Service("UNION_DeShiPay")
public class DeShiUnionPayServiceImpl implements BaseTranService {
	private static Logger log = LoggerFactory
			.getLogger(DeShiUnionPayServiceImpl.class);

			
	private static Properties myProp = ConfigUtils.loadProperties("mpaychl/conf-chl-properties/DeShiPay.properties");

	private static String signKeyName = "sign";

	private static String charset = "utf-8";
	private static String SignType = "RSA2";

	/** 收单平台公钥 */
	public static String DESHI_PUB_KEY = myProp.getProperty("pub_deshi");
	/** 默认商户私钥 */
	public static String DESHI_PRV_DEFULT = myProp.getProperty("prv_defult");

	private static PrivateKey merPrivateKey;
	
	private static PublicKey acqPublicKey;
	
	@Override
	public Map<String, Object> execute(Map<String, Object> param)
			throws TranException {
		log.info("进入自有跳转处理接口 [{}]", param);
		// 路由编码
		String rtrcod = (String) param.get("rtrcod");
		String nodeId = rtrcod;
		if (StringUtil.isEmpty(param.get("merKey"))) {
			param.put("merKey", DESHI_PRV_DEFULT);
		}
		try {
			// 公共参数设置
			if ("union_pay".equals(rtrcod)) {// 下单
				return pay(param);
			} else if ("pay_query".equals(rtrcod) || "pay_que".equals(rtrcod)) {// 交易查询
				return payQuery(param);
				// } else if ("withdrawal".equals(rtrcod)) {// 提现
				// return withdrawal(param);
				// } else if ("withdrawalQuery".equals(rtrcod) ||
				// "cas_que".equals(rtrcod)) {// 代付结果查询
				// return withdrawalQuery(param);
			} else {
				throw new BusinessException(ExcepCode.EX900003, "不支持的路由编码[{}]",
						rtrcod);
			}
		} catch (TranException e) {
			throw e;
		} catch (Exception e) {
			e.printStackTrace();
			log.error("渠道调用异常:" + e.getMessage(), e);
			throw new BusinessException(ExcepCode.EX900001, "执行出错");
		}
		// return new HashMap<String, Object>();
	}

	public static boolean verifySign(String signPubKey, Map<String, Object> signMap)
			throws Exception {
		//verify sign key
		KeyFactory keyFactory = KeyFactory.getInstance("RSA");
		byte[] encodedKey = Base64.decodeBase64(new String(signPubKey));
		PublicKey acqPubKey = keyFactory.generatePublic(new X509EncodedKeySpec(
				encodedKey));
		
		log.info("验签开始...");
		String chlSign = ObjectUtil.getString(signMap.get(signKeyName));
		log.info("渠道签名[{}]", chlSign);

		//signMap.remove(signKeyName);
		
//		String signStr = MapUtils.getSignStrByMap(signMap, true);

		String signStr = JUtil.toJsonString(signMap);		
		Map<String, String> resp = new HashMap<String, String>();
		//Map<String,String> resp = new TreeMap<String,String>();
		//resp = JsonUtil.fromJson(signStr, Map.class);
		resp = JUtil.fromJson(signStr, Map.class);
		
		byte[] signature = hexDecode(resp.remove(signKeyName));
		byte[] raw = sha1(sort(resp).getBytes("utf-8")).getBytes();
		Signature st = Signature.getInstance("SHA1withRSA");
		st.initVerify(acqPubKey);
		st.update(raw);
		if (!st.verify(signature)) {
			throw new RuntimeException("验证签名失败");
		}
		
		log.info("签名原串:[{}]", signStr);
		return true;
		// return RSAUtil.rsaCheck(signStr, chlSign, signKey, charset);
	}

	public static boolean verifySign(String signKey, String signStr,
			String chlSign) throws Exception {
		log.info("渠道签名[{}]", chlSign);
		log.info("签名原串:[{}]", signStr);
		return RSAUtil.rsa256CheckContent(signStr, chlSign, signKey, charset);
		// return RSAUtil.rsaCheck(signStr, chlSign, signKey, charset);
	}

	public static String sign(String signKey, Map<String, String> signMap)
			throws Exception {
		PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(
				Base64.decodeBase64( signKey ));
		KeyFactory keyf = KeyFactory.getInstance("RSA");
		PrivateKey merPrivkey = keyf.generatePrivate(priPKCS8);
		
		String signStr = MapUtils.getSignStrByMap(signMap, true);
		log.info("签名原串:[{}]", signStr);
		byte[] raw = sha1(sort(signMap).getBytes("utf-8")).getBytes();
		Signature st = Signature.getInstance("SHA1withRSA");
		st.initSign(merPrivkey);
		st.update(raw);
		String sign = EncodeUtils.hexEncode(st.sign());
		log.info("签名结果:[{}]", sign);
		return sign;
	}
	
	/**
	 * 设置RSA签名参数，只需初始化一次。
	 * 
	 * @param strMerPriCert
	 *            商户私钥证书(商户签名使用)
	 * @param strAcqPubCert
	 *            收单平台证书(商户验证签名使用)
	 */
	public static void setRSAParams(String strMerPriCert, String strAcqPubCert)
			throws Exception {
		if (!StringUtil.isEmpty(strMerPriCert) ) {
			PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(
					Base64.decodeBase64( strMerPriCert ));
			KeyFactory keyf = KeyFactory.getInstance("RSA");
			merPrivateKey = keyf.generatePrivate(priPKCS8);
			log.info("Init privateKey successfully");
		}
		if (!StringUtil.isEmpty(strAcqPubCert)) {
			KeyFactory keyFactory = KeyFactory.getInstance("RSA");
			byte[] encodedKey = Base64.decodeBase64(new String(strAcqPubCert));
			acqPublicKey = keyFactory.generatePublic(new X509EncodedKeySpec(
					encodedKey));
			log.info("SecService init acq.cer successfully");
		}
	}
	
	private static String sort(Map<String, String> request) {
		String[] keys = request.keySet().toArray(new String[0]);
		Arrays.sort(keys);
		StringBuilder raw = new StringBuilder();
		for (String key : keys) {
			raw.append(key).append("=").append(request.get(key)).append("&");
		}
		return raw.deleteCharAt(raw.length() - 1).toString();
	}
	
	private static String sha1(byte[] raw) {

		MessageDigest messageDigest;
		try {
			messageDigest = MessageDigest.getInstance("SHA-1");
			messageDigest.reset();
			messageDigest.update(raw);
			byte[] bytes = messageDigest.digest();
			return EncodeUtils.hexEncode(bytes);
		} catch (Exception e) {
			throw new RuntimeException("SHA-1 algorithm not supported", e);
		}
	}
	
	private static byte[] hexDecode(String input) {
		try {
			return Hex.decodeHex(input.toCharArray());
		} catch (DecoderException e) {
			throw new IllegalStateException("Hex Decoder exception", e);
		}
	}

//	public static String sign(String signKey, Map<String, Object> signMap)
//			throws Exception {
//		Map<String, Object> map = new TreeMap<>(signMap);
//		map.remove(signKeyName);
//		String signStr = MapUtils.getSignStrByMap(map, true);
//		log.info("签名原串:[{}]", signStr);
//		String sign = RSAUtil.rsa256Sign(signStr, signKey, charset);
//		log.info("签名结果:[{}]", sign);
//		return sign;
//	}
	

	private Map<String, Object> sendHttpRequest(String url,
			Map<String, Object> paramMap) throws Exception {
		Map<String, Object> requestHead = new LinkedHashMap<>();
		//requestHead.put("Content-Type","application/json; charset=UTF-8");
		String resStr = HttpUtil.httpRequest(url, paramMap,
				HttpUtil.HTTP_METHOD_POST, charset, requestHead);
		log.info("返回:[{}]", resStr);
		Map<String, Object> resMap = JUtil.toMap(resStr);

		return resMap;
	}

	public Map<String, Object> pay(Map<String, Object> param) throws Exception {
		log.info("[DeShiPay]下单接口:[{}]", param);
		ParamValidate.doing(param, "TMercId", "merKey", "prdOrdNo", "payAmt",
				"rateType");

		String signKey = (String) param.get("merKey");
		
		String orderNo = (String) param.get("prdOrdNo");

		Map<String, Object> paramMap = new TreeMap<String, Object>();
		//paramMap.put("out_trade_no", param.get("prdOrdNo"));
		
		String payAmt = ObjectUtil.getString(param.get("payAmt"));
		log.info("支付金额[{}分]", payAmt);
		payAmt = MoneyUtils.toStrYuan(payAmt);
		log.info("支付金额转换为元[{}]", payAmt);

		paramMap.put("total_amount", payAmt);
		paramMap.put("subject", param.get("prdOrdNo"));
		// paramMap.put("body", "商家收款:订单号" + param.get("prdOrdNo"));

		String rateType = ObjectUtil.getString(param.get("rateType"));
		log.info("费率类型[{}]", rateType);
		if (MsgCT.RATE_TYPE_ZHIFUBAO_API.equals(rateType)) {
			;
		} else if (MsgCT.RATE_TYPE_ZHIFUBAO_H5.equals(rateType)
				|| MsgCT.RATE_TYPE_ZHIFUBAO_H5_API.equals(rateType)) {
			;
		} else {
			throw new BusinessException(ExcepCode.EX900000, "不支持的费率类型[{}]",
					rateType);
		}

		Map<String, String> reqMap = new HashMap<String, String>();
		reqMap.put("version", "1.0");
		//reqMap.put("sign", signKey);
		reqMap.put("mer_code",  (String)param.get("TMercId"));
		reqMap.put("sign_method",  (String)param.get("sign_method"));
		reqMap.put("trans_code",  (String)param.get("trans_code"));
		reqMap.put("order_no", orderNo); //商户订单号
		reqMap.put("txn_date",  (String)param.get("txn_date"));
		reqMap.put("front_url", (String)param.get("front_url"));//TODO：notify_url
		reqMap.put("back_url", (String)param.get("back_url"));//TODO：make_url
		reqMap.put("amount", ObjectUtil.getString(param.get("payAmt"))); //交易金额
		reqMap.put("currency", (String)param.get("currency"));
		reqMap.put("bank_code", (String)param.get("bank_code"));
		
		//reqMap.put("name", (String)param.get("name"));//商户
		//reqMap.put("id_type", (String)param.get("id_type"));
		//reqMap.put("card_no", (String)param.get("card_no"));
		//reqMap.put("id_no",  (String)param.get("id_no"));
		//reqMap.put("phone", (String)param.get("phone"));
		//reqMap.put("cvn2", (String)param.get("cvn2"));
		//reqMap.put("expired", (String)param.get("expired"));
		
		//reqMap.put("sms_code", (String)param.get("sms_code"));
		//reqMap.put("org_order_no", (String)param.get("org_order_no"));//原交易订单号
		//reqMap.put("org_txn_date",  (String)param.get("org_txn_date")); //原交易订单时间
		//reqMap.put("sms_type", (String)param.get("sms_type"));
		
		//reqMap.put("sign_type", SignType);
		//reqMap.put("method", "DeShiPay.trade.precreate");
		//reqMap.put("format", "JSON");
		//reqMap.put("charset", charset);
		//reqMap.put("timestamp", DateUtils.formatCurrentDateTime(DateUtils.DATETIME_FORMAT_4));
		
		//reqMap.put("biz_content", JUtil.toJsonString(paramMap));
		
		
		reqMap.put(signKeyName, sign(signKey, reqMap));

		String url = myProp.getProperty("union_pay_url");
		
		String resStr = JUtil.toJsonString(reqMap);
		Map<String, Object> myReqMap = JUtil.toMap(resStr);

		Map<String, Object> resMap = sendHttpRequest(url, myReqMap);

		Map<String, Object> backMap = new HashMap<>();
		backMap.put("ordStatus", MsgCT.ORDSTATUS_PROCESSING);
		backMap.put("payAmt", myReqMap.get("amount"));
		backMap.put("txAmt", payAmt);

		Map<String, Object> resTrade = (Map<String, Object>)resMap.get("DeShiPay_trade_precreate_response");

		String codeUrl = ObjectUtil.getString(resTrade.get("qr_code"));
		
		 String chlSign = ObjectUtil.getString(resMap.get(signKeyName));
		 String signStr = "DeShiPay_trade_precreate_response=" +
		 JUtil.toJsonString(resTrade).replaceAll("/", "\\/");
		
			//验签	
		 if (!verifySign(DESHI_PUB_KEY, resMap)) {
			 backMap.put("ordStatus", MsgCT.ORDSTATUS_FAIL);
			 backMap.put("msg", "交易验签失败，为了您的交易安全，请重新发起！");
			 return backMap;
		 }

		if (StringUtil.isEmpty(codeUrl)) {
			backMap.put("ordStatus", MsgCT.ORDSTATUS_FAIL);
			backMap.put("msg", resTrade.get("msg"));
		} else {
			if (MsgCT.RATE_TYPE_ZHIFUBAO_H5.equals(rateType)
					|| MsgCT.RATE_TYPE_ZHIFUBAO_H5_API.equals(rateType)) {
				String html = MapUtils.getForwardHtml(codeUrl);
				// html = html.replaceAll("method=\"post\"", "method=\"get\"");
				backMap.put("busContent", html);
				backMap.put("contentType", MsgCT.DATA_TYPE_HTML);
				return backMap;
			}
			backMap.put("busContent", codeUrl);
		}

		return backMap;
	}

	/**
	 * 交易结果查询
	 * 
	 * @param param
	 * @return
	 * @throws Exception
	 */
	public Map<String, Object> payQuery(Map<String, Object> param)
			throws Exception {
		log.info("[DeShiPay]支付结果查询调用:" + param);
		// 参数非空验证
		ParamValidate.doing(param, "TMercId", "merKey", "prdOrdNo");

		String orderNo = (String) param.get("prdOrdNo");
		
		String signKey = (String) param.get("merKey");

		String action = "cashier/query.ac";// 订单查询;
		
//		Map<String, Object> paramMap = new TreeMap<String, Object>();
		Map<String, String> paramMap = new HashMap<String, String>();
		// 订单查询Post字段M
		paramMap.put("version", "1.0");
		//paramMap.put("sign", signKey);
		paramMap.put("mer_code",  (String)param.get("TMercId"));
		paramMap.put("sign_method",  (String)param.get("sign_method"));
		paramMap.put("trans_code",  (String)param.get("trans_code"));
		paramMap.put("order_no", orderNo);
		paramMap.put("txn_date",  (String)param.get("txn_date"));
		
		//签名
		paramMap.put(signKeyName, sign(signKey, paramMap));
		//SecService.addSignature( paramMap );
		
		String resStr = JUtil.toJsonString(paramMap);
		Map<String, Object> reqMap = JUtil.toMap(resStr);
		
		String url = myProp.getProperty("pay_query");
		Map<String, Object> resMap = sendHttpRequest(url, reqMap);
//		Map<String, Object> resMap = sendHttpRequest(url, paramMap);

		String status = ObjectUtil.getString(resMap.get("resp_code"));

		Map<String, Object> backMap = new HashMap<String, Object>();
		backMap.put("order_no", orderNo);
		backMap.put("ordStatus", MsgCT.ORDSTATUS_PROCESSING);

		//验签	
		if (!verifySign(DESHI_PUB_KEY, resMap)) {
			throw new BusinessException(ExcepCode.EX900000, "查询返回验签失败!");
		}

		if ("01".equals(status)) {
			backMap.put("ordStatus", MsgCT.ORDSTATUS_SUCCESS);
		} else if ("02".equals(status)) {
			backMap.put("ordStatus", MsgCT.ORDSTATUS_FAIL);
		}
		return backMap;
	}

	/**
	 * 提现
	 * 
	 * @param param
	 * @return
	 * @throws Exception
	 */
	public Map<String, Object> withdrawal(Map<String, Object> param)
			throws Exception {
		log.info("[DeShiPay]提现调用:" + param);
		// 参数非空验证
		ParamValidate.doing(param, "TMercId", "merKey", "casOrdNo",
				"netrecAmt", "cardNo", "accountName");

		String orderNo = (String) param.get("casOrdNo");
		String casDesc = (String) param.get("casDesc");
		if (StringUtils.isEmpty(casDesc)) {
			casDesc = "API余额代付";
		}

		Map<String, Object> paramMap = new TreeMap<String, Object>();
		paramMap.put("version", "2.1");
		paramMap.put("orgNo", param.get("TTermId"));
		paramMap.put("custId", param.get("TMercId"));
		paramMap.put("custOrdNo", orderNo);
		paramMap.put("casType", "00");
		paramMap.put("casAmt", param.get("netrecAmt"));// 分
		paramMap.put("accountName", param.get("accountName"));
		paramMap.put("cardNo", param.get("cardNo"));

		String cnapsCode = ObjectUtil.getString(param.get("cnapsCode"));

		paramMap.put("cnapsCode", cnapsCode);

		String signKey = (String) param.get("merKey");

		String url = myProp.getProperty("cas_url");

		//paramMap.put(signKeyName, sign(signKey, paramMap));
		Map<String, Object> resMap = sendHttpRequest(url, paramMap);

		Map<String, Object> backMap = new HashMap<String, Object>();
		backMap.put("ordStatus", MsgCT.CAS_ORD_STATUS_06);
		backMap.put("casDesc", resMap.get("msg"));

		String status = ObjectUtil.getString(resMap.get("ordStatus"));
		if ("08".equals(status)) {// 失败
			backMap.put("casDesc", "代付失败:" + resMap.get("msg"));
		}

		return backMap;
	}

	/**
	 * 提现结果查询
	 * 
	 * @param param
	 * @return
	 * @throws Exception
	 */
	public Map<String, Object> withdrawalQuery(Map<String, Object> param)
			throws Exception {
		log.info("[DeShiPay]提现结果查询:" + param);
		// 参数非空验证
		ParamValidate.doing(param, "TMercId", "merKey", "casOrdNo");
		String orderNo = (String) param.get("casOrdNo");

		Map<String, Object> paramMap = new TreeMap<String, Object>();
		paramMap.put("version", "2.1");
		paramMap.put("orgNo", param.get("TTermId"));
		paramMap.put("custId", param.get("TMercId"));
		paramMap.put("custOrdNo", orderNo);

		String signKey = (String) param.get("merKey");

		String url = myProp.getProperty("cas_query");

		//paramMap.put(signKeyName, sign(signKey, paramMap));
		Map<String, Object> resMap = sendHttpRequest(url, paramMap);

		Map<String, Object> backMap = new HashMap<String, Object>();
		backMap.put("ordStatus", MsgCT.CAS_ORD_STATUS_06);
		backMap.put("casDesc", resMap.get("msg"));

		String status = ObjectUtil.getString(resMap.get("ordStatus"));
		if ("08".equals(status)) {// 失败
			backMap.put("casDesc", "代付失败:" + resMap.get("msg"));
		} else if ("07".equals(status)) {
			backMap.put("ordStatus", MsgCT.CAS_ORD_STATUS_07);
		}

		return backMap;
	}

	public static void main(String[] args) throws Exception {
		
		DeShiUnionPayServiceImpl service = new DeShiUnionPayServiceImpl();
		
//		SecService.setRSAParams("D:/TDProject/allpay_BLS/server/mpaychl-bls-it/src/main/resources/rsa_private_key.pem", "D:/TDProject/allpay_BLS/server/mpaychl-bls-it/src/main/resources/deshiPub.pem"); //TODO 不管用何种签名方式,如果需上送encrypted_pin,需要执行本条语句
		
		
		Map<String, Object> merParam = new HashMap<String, Object>();

		merParam.put("TMercId", "880201809260075");
		merParam.put("TTermId", "001");
		merParam.put("merKey", DESHI_PRV_DEFULT);
		merParam.put("merKeyCV", "121");
		
		//merParam.put("mer_code", "880201809260075");
		//merParam.put("version", "1.0");
		merParam.put("sign_method", "01");
		//merParam.put("sign", DESHI_PRV_DEFULT);
		//merParam.put("trans_code", "90");
        //merParam.put("custId", "880201809260075");
		
		
		//TODO 按接口规范初始化请求报文
		merParam.put("back_url", myProp.getProperty("pay_call_back_url"));// TODO 商户接收后台通知的URL地址（一般是servlet实现）
		merParam.put("front_url", "localhost");// TODO 商户接收前台通知的URL地址（一般是servlet实现）


		{
			// 支付
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("rtrcod", "union_pay");

			param.putAll(merParam);
			
			//param.put("version", "1.0");
			param.put("trans_code", "03");
			param.put("order_no", "20180927900007"); //商户订单号
			param.put("txn_date", DateUtils.formatCurrentDateTime(DateUtils.DATETIME_FORMAT_1) );//订单发送时间
			param.put("amount", "250"); //交易金额
			param.put("currency", "156");
			param.put("name", "张三");
			//param.put("id_type", "01");
			//param.put("card_no", "6226090000000048");
			//param.put("id_no", "510265790128303");
			param.put("bank_code", "ICBC");
			//param.put("phone", "18100000000");
			//param.put("cvn2", "678");
			//param.put("expired", "0929");
			
			//param.put("sms_code", "111111");
			//param.put("org_order_no", "20180927900003");//原交易订单号
			//param.put("org_txn_date", DateUtils.formatCurrentDateTime(DateUtils.DATETIME_FORMAT_1) ); //原交易订单时间
			

			param.put("payAmt", "250");
			// param.put("payType", "07");
			param.put("rateType", "0502");
			// param.put("rateType", "0506");
			//param.put("goodsName", "特斯塔");
			param.put("prdOrdNo",
					DateUtils.getCurrentDateTime() + StringUtil.getRandomNum(6));

//			Map<String, Object> resMap = service.execute(param);
//			System.out.println("返回结果:" + resMap);
		}

		{
			// 订单状态查询
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("rtrcod", TranCode.TRAN_PAY_QUERY);

			param.putAll(merParam);
			
			//param.put("version", "1.0");
			param.put("trans_code", "90");
			//param.put("order_no", "20180927900007"); //商户订单号
			param.put("txn_date", DateUtils.formatCurrentDateTime(DateUtils.DATETIME_FORMAT_1) );//订单发送时间
			param.put("prdOrdNo", "20180927900020");//订单号
			
			Map<String, Object> resMap = service.execute(param);
			System.out.println("返回结果:" + resMap);
		}

		{
			// 提现
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("rtrcod", "withdrawal");

			param.putAll(merParam);

			param.put("netrecAmt", "100");
			param.put("casOrdNo", System.currentTimeMillis() + "");
			param.put("accountName", "测试");
			param.put("cardNo", "6228480328592378471");
			param.put("bankName", "中国农业银行");

			// param.put("bankName","");
			// param.put("bankPro","浙江省");
			// param.put("bankCity","杭州市");
			// param.put("subBranch","中国农业银行杭州文新路支行");
			// param.put("cnapsCode","103331000074");

			// Map<String, Object> resMap = service.execute(param);
			// System.out.println("返回结果:" + resMap);
		}
		{
			// 提现查询
			Map<String, Object> param = new HashMap<String, Object>();
			param.put("rtrcod", TranCode.TRAN_WITHDRAWAL_QUERY);

			param.putAll(merParam);

			// merParam.put("TMercId", "9000000");
			// merParam.put("TTermId", "9000000");
			// merParam.put("merKey", "3lu4L2f93X21Y5Ok36HD");
			// merParam.put("merKeyCV", "8800008501797");

			param.put("casOrdNo", "1519811576373");

			// Map<String, Object> resMap = service.execute(param);
			// System.out.println("返回结果:" + resMap);
		}
	}

}
